<template>
      
  <div
     class="app-container">
    <div class="el-toolbar">
      <div class="el-toolbar-body"style="justify-content: flex-start;">
        <el-button type="text"@click="exportData"><i class="fa fa-plus"/> 导出</el-button>
      </div>
    </div>
    <el-table
              :data="list"
              style="width: 100%"
              row-key="id"
              border
              lazy
              :load="load"
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
      <el-table-column
        prop="name"
        label="名称"
        width="180">
      </el-table-column>
      <el-table-column
        prop="dictCode"
        label="编码"
        width="180">
      </el-table-column>
      <el-table-column
        prop="value"
        label="值"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="180">
      </el-table-column>  
    </el-table>
        
  </div>
</template>

<script>
  import dict from "@/api/dict";

  export default {
    name: "list",
    data() {
      return {
        list: []
      }
    },
    created() {
      this.getDictList(1);
    },
    methods: {
      exportData(){
        window.location.href = 'http://localhost:8202/admin/cmn/dict/exportData'
       // dict.exportData()

      },
      getDictList(id) {
        dict.dictList(id)
          .then(response => {
            console.log(response.data)
            this.list = response.data;
          })
          .catch(error => {
            this.$message({
              type: 'error',
              message: error.message
            })
          })
      },
      load(tree, treeNode, resolve) {
        console.log("tree.id" + tree.id)
        dict.dictList(tree.id)
          .then(response => {
            resolve(response.data)
          })
          .catch()
      }
    }
  }
</script>

